<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-card>
        <el-form-item label="名称" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入站点名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="代码" prop="code">
          <el-input
            v-model="queryParams.code"
            placeholder="请输入站点代码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="启用日期" prop="startTime">
          <el-date-picker clearable size="small" style="width:100%;" v-model="queryParams.startTime" type="date" value-format="yyyy-MM-dd" placeholder="选择启用日期"></el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="关停日期" prop="endTime">
          <el-date-picker clearable size="small" style="width:100%;" v-model="queryParams.endTime" type="date" value-format="yyyy-MM-dd" placeholder="选择关停日期"></el-date-picker>
        </el-form-item> -->
        <el-form-item label="状态 " prop="status">
          <el-select v-model="queryParams.status" placeholder="请选择站点状态 " clearable size="small">
            <el-option
              v-for="(dict,index) in dict.type.sys_station_status"
              :key="'b'+index"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-card>
    </el-form>

    <el-card style="margin-top:10px;">
      <el-table v-loading="loading" :data="stationList" @selection-change="handleSelectionChange" border>
        <el-table-column label="站点名称" align="center" prop="name" />
        <el-table-column label="站点代码" align="center" prop="code" />
        <el-table-column label="启用日期" align="center" prop="startTime">
          <template slot-scope="scope">
            <span v-if="scope.row.startTime!=null">{{ scope.row.startTime }}</span>
            <span v-if="scope.row.startTime==null" style="color:gray;">-</span>
          </template>
        </el-table-column>
        <el-table-column label="关停日期" align="center" prop="endTime">
          <template slot-scope="scope">
            <span v-if="scope.row.endTime!=null">{{ scope.row.endTime }}</span>
            <span v-if="scope.row.endTime==null" style="color:gray;">-</span>
          </template>
        </el-table-column>
        <el-table-column label="负责人" align="center" prop="chargerName" />
        <el-table-column label="负责部门" align="center" prop="deptName" />
        <el-table-column label="联系人" align="center" prop="contactPerson" />
        <el-table-column label="联系方式" align="center" prop="contactPhone" />
        <el-table-column label="站点状态" align="center" prop="status">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_station_status" v-if="scope.row.status==0" style="color:blue;" :value="scope.row.status"/>
            <dict-tag :options="dict.type.sys_station_status" v-if="scope.row.status==1" style="color:green;" :value="scope.row.status"/>
            <dict-tag :options="dict.type.sys_station_status" v-if="scope.row.status==2" style="color:red;" :value="scope.row.status"/>
            <dict-tag :options="dict.type.sys_station_status" v-if="scope.row.status==3" style="color:gray;" :value="scope.row.status"/>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-dropdown :hide-on-click="false">
              <span class="el-dropdown-link" style="color:blue;">
                更多操作<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="handleView(scope.row)"><i class="el-icon-document"></i>站点详情</el-dropdown-item>
                <el-dropdown-item style="color:blue;" @click.native="handleUpdate(scope.row)"><i class="el-icon-edit-outline"></i>站点修改</el-dropdown-item>
                <el-dropdown-item style="color:green;" v-if="scope.row.status==0" @click.native="handleStart(scope.row)"><i class="el-icon-s-promotion"></i>投入运营</el-dropdown-item>
                <el-dropdown-item style="color:red;" v-if="scope.row.status==1" @click.native="handleFinish(scope.row)"><i class="el-icon-s-help"></i>站点关停</el-dropdown-item>
                <el-dropdown-item style="color:gray;" v-if="scope.row.status==0" @click.native="handleNullify(scope.row)"><i class="el-icon-delete"></i>站点作废</el-dropdown-item>
                <el-dropdown-item style="color:blue;" v-if="scope.row.status==2||scope.row.status==3" @click.native="handleRestart(scope.row)"><i class="el-icon-refresh"></i>重启站点</el-dropdown-item>
                <el-dropdown-item style="color:red;" v-if="scope.row.status==3" @click.native="handleDelete(scope.row)"><i class="el-icon-delete-solid"></i>站点删除</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
    <!-- 详情 -->
    <el-dialog :title="vTitle" :visible.sync="vOpen" width="70%" append-to-body>
      <el-card style="margin-top:-30px">
        <div slot="header" class="clearfix">
          <center><span style="font-weight:bold;font-size:18px;">{{ stationDetail.name }}</span></center>
        </div>
        <el-descriptions :column="2" border>
          <el-descriptions-item label="站点代码" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ stationDetail.code }}
          </el-descriptions-item>
          <el-descriptions-item label="站点状态" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            <dict-tag :options="dict.type.sys_station_status" :value="stationDetail.status"/>
          </el-descriptions-item>
          <el-descriptions-item label="启动日期" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            <span v-if="stationDetail.startTime!=null">{{ stationDetail.startTime }}</span>
            <span v-if="stationDetail.startTime==null" style="color:gray;">-</span>
          </el-descriptions-item>
          <el-descriptions-item label="竣工日期" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            <span v-if="stationDetail.endTime!=null">{{ stationDetail.endTime }}</span>
            <span v-if="stationDetail.endTime==null" style="color:gray;">-</span>
          </el-descriptions-item>
          <el-descriptions-item label="负责人" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ stationDetail.chargerName }}
          </el-descriptions-item>
          <el-descriptions-item label="负责部门" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ stationDetail.deptName }}
          </el-descriptions-item>
          <el-descriptions-item label="联系人" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ stationDetail.contactPerson }}
          </el-descriptions-item>
          <el-descriptions-item label="联系方式" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ stationDetail.contactPhone }}
          </el-descriptions-item>
          <el-descriptions-item label="创建人" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ stationDetail.creator }}
          </el-descriptions-item>
          <el-descriptions-item label="创建时间" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            <span>{{ parseTime(stationDetail.createTime, '{y}-{m}-{d}') }}</span>
          </el-descriptions-item>
        </el-descriptions>
        <el-descriptions :column="1" border style="margin-top:-2px;">
          <el-descriptions-item label="站点描述" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'90%',color: '#329dff' }">
            {{ stationDetail.describe }}
          </el-descriptions-item>
          <el-descriptions-item label="补充说明" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'90%',color: '#329dff' }">
            {{ stationDetail.remark }}
          </el-descriptions-item>
        </el-descriptions>
      </el-card>
      <el-card style="margin-top:10px;">
        <div slot="header" class="clearfix">
          <span style="font-weight:bold;color:#1890FF;">站点图片</span>
        </div>
        <new-preview v-if="stationDetail.imgAttach!=null" :src="stationDetail.imgAttach" :width="200" :height="200" />
      </el-card>

      <el-card style="margin-top:10px;">
        <div slot="header" class="clearfix">
          <span style="font-weight:bold;color:#1890FF;">站点附件</span>
        </div>
        <file-upload-show :fileList_show="fileList_show" />
      </el-card>

      <el-card style="margin-top:10px;">
        <div slot="header" class="clearfix">
          <span style="font-weight:bold;color:#1890FF;">站点数据集</span>
        </div>
        <el-table :data="stationDatasetsList" border ref="table1">
          <el-table-column type="selection" width="50" align="center" :selectable="selectable" />
          <el-table-column label="序号" align="center" type="index" />
          <el-table-column label="名称" align="center" prop="name" />
          <el-table-column label="编码" align="center" prop="code" />
          <el-table-column label="类型" align="center" prop="type" width="120">
          <template slot-scope="scope">
              <dict-tag :options="dict.type.sy_dataset_type" :value="scope.row.type"/>
          </template>
          </el-table-column>
          <el-table-column label="状态" align="center" prop="status" width="120">
          <template slot-scope="scope">
              <dict-tag :options="dict.type.sy_dataset_status" v-if="scope.row.status==0" style="color:blue" :value="scope.row.status"/>
              <dict-tag :options="dict.type.sy_dataset_status" v-if="scope.row.status==1" style="color:green" :value="scope.row.status"/>
              <dict-tag :options="dict.type.sy_dataset_status" v-if="scope.row.status==2" style="color:red" :value="scope.row.status"/>
          </template>
          </el-table-column>
          <el-table-column label="创建人" align="center" prop="creator" width="120" />
          <el-table-column label="创建日期" align="center" prop="createTime" width="120">
          <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          </template>
          </el-table-column>
          <el-table-column label="发布人员" align="center" prop="publisher" width="120" />
          <el-table-column label="发布日期" align="center" prop="publishTime" width="120">
          <template slot-scope="scope">
              <span>{{ parseTime(scope.row.publishTime, '{y}-{m}-{d}') }}</span>
          </template>
          </el-table-column>
        </el-table>
      </el-card>

      <el-card style="margin-top:10px;">
        <div slot="header" class="clearfix">
          <span style="font-weight:bold;color:#1890FF;">站点待办事项</span>
        </div>
        <el-table :data="itemsList" border>
          <el-table-column label="序号" align="center" type="index" />
          <el-table-column label="事项标题" align="left" prop="itemName" />
          <el-table-column label="发起人" align="center" prop="createName" width="100" />
          <el-table-column label="发起日期" align="center" prop="createTime" width="120">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="当前跟进人" align="center" prop="followupName" width="120">
            <template slot-scope="scope">
              <span v-if="scope.row.status==2">-</span>
              <span v-if="scope.row.status!=2">{{scope.row.followupName}}</span>
            </template>
          </el-table-column>
          <el-table-column label="跟进状态" align="center" prop="status" width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.status==0" style="color:blue;">待跟进</span>
              <span v-if="scope.row.status==1" style="color:red;">跟进中</span>
              <span v-if="scope.row.status==2" style="color:green;">已结束</span>
            </template>
          </el-table-column>
          <el-table-column label="截止日期" align="center" prop="deadTime" width="120" />
        </el-table>
      </el-card>

      <div slot="footer" class="dialog-footer" v-if="startSatation==true||finishStation==true||nullifyStation==true||deleteStation==true||restartStation==true">
        <el-button type="success" v-show="startSatation" @click="processStartStation(stationDetail)">站点启动</el-button>
        <el-button type="warning" v-show="finishStation" @click="processFinishStation(stationDetail)">站点关停</el-button>
        <el-button type="info" v-show="nullifyStation" @click="processNullifyStation(stationDetail)">站点作废</el-button>
        <el-button type="primary" v-show="restartStation" @click="processRestartStation(stationDetail)">重启站点</el-button>
        <el-button type="danger" v-show="deleteStation" @click="processDeleteStation(stationDetail)">站点删除</el-button>
      </div>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog :title="title" :visible.sync="open" width="70%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <el-card style="margin-top:-2px;">
          <div slot="header" class="clearfix">
            <span style="color:#329dff;font-weight:bold;font-size:14px;">站点信息</span>
          </div>

          <el-row>
              <el-col :span="12">
                <el-form-item label="站点代码" prop="code">
                  <el-input v-model="form.code" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="站点名称" prop="name">
                  <el-input v-model="form.name" />
                </el-form-item>
              </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="负责人" prop="chargerId">
                <el-select v-model="form.chargerId" filterable placeholder="请选择负责人" style="width:100%;">
                  <el-option v-for="item in participants" :key="item.userId" :label="item.nickName" :value="item.userId"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="负责部门" prop="deptId">
                <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择负责部门" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="启用日期" prop="startTime">
                <el-date-picker clearable size="small" style="width:100%;" v-model="form.startTime" type="date" value-format="yyyy-MM-dd" placeholder="选择启动日期"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="关停日期" prop="endTime">
                <el-date-picker clearable size="small" style="width:100%;" v-model="form.endTime" type="date" value-format="yyyy-MM-dd" placeholder="选择竣工日期"></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
            <el-form-item label="联系人" prop="contactPerson">
              <el-input v-model="form.contactPerson" />
            </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="联系方式" prop="contactPhone">
                <el-input v-model="form.contactPhone" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="24">
              <el-form-item label="站点地址" prop="address">
                <el-input v-model="form.address" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="24">
              <el-form-item label="站点描述" prop="describe">
                <el-input type="textarea" v-model="form.describe" :rows="10"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="24">
              <el-form-item label="备注说明" prop="remark">
                <el-input type="textarea" v-model="form.remark" :rows="10"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

        </el-card>

        <el-card style="margin-top:10px;">
          <div slot="header" class="clearfix">
            <span style="color:#329dff;font-weight:bold;font-size:14px;">站点附件</span>
          </div>
          <el-row>
            <el-col :span="24">
              <el-form-item prop="imgAttach">
                <image-upload-custom v-model="form.imgAttach" :limit="10000" :imageName="imageName"></image-upload-custom>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item prop="fileAttach">
                <file-upload-custom
                  :fileSize="10000"
                  :attachName="attachOtherName"
                  :fileList_show="fileList_show"
                  v-model="form.fileAttach"
                  @addlist="fileList_show_add"
                  @deletlist="fileList_show_delet"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listStation,getStation,editStation,processStartStation,processFinishStation,processNullifyStation,processRestartStation,processDeleteStation } from "@/api/system/station";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { listAllUser } from "@/api/system/user";
import { getBindStationDatasets } from "@/api/system/dataset";
import { getItemListByItemParentId } from "@/api/system/items";

export default {
  name: "QueryStation",
  dicts: ['sys_station_status'],
  components:{ Treeselect },
  data() {
    return {
      itemsList: [],
      attachPdfName: '上传PDF',
      attachOtherName: '上传文件',
      imageName: '上传图片',
      participants: [],
      deptOptions: [],
      fileList_show:[],
      stationDetail: {},
      startSatation: false,
      finishStation: false,
      nullifyStation: false,
      deleteStation: false,
      restartStation: false,
      moneyFormat: 4,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 站点信息表表格数据
      stationList: [],
      stationDatasetsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      vOpen: false,
      // 弹出层标题
      vTitle: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        code: null,
        startTime: null,
        endTime: null,
        status: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        projectNo: [
          { required: true, message: "站点编号不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.listAllUser();
    this.getTreeselect();
  },
  methods: {
    selectable(row, index) {
      if (row.hasProject == 1) {
        return false; // 禁用
      } else {
        return true; //不禁用
      }
    },
    getRowKeys(row) {
      return row.uuid;
    },
    /** 查询站点信息表列表 */
    getList() {
      this.loading = true;
      listStation(this.queryParams).then(response => {
        this.stationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        uuid: null,
        projectNo: null,
        name: null,
        code: null,
        startTime: null,
        endTime: null,
        describe: null,
        status: null,
        chargerId: null,
        deptId: null,
        contactPerson: null,
        contactPhone: null,
        totalInvest: null,
        constructDept: null,
        constructSite: null,
        supervisor: null,
        contractAttach: null,
        materialAttach: null,
        roleIds: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.uuid)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加站点信息";
    },
    handleView(row){
      this.fileList_show = [];
      this.stationDetail = {};
      getStation(row.uuid).then(res => {
        this.stationDetail = res.data;
        this.vOpen = true;
        this.vTitle = "站点详情";
        this.fileList_show = res.data.attachList;
        this.startSatation = false;
        this.finishStation = false;
        this.nullifyStation = false;
        this.deleteStation = false;
        this.restartStation = false;
        //获取数据集
        let query = {
            stationIds: row.uuid
        }
        getBindStationDatasets(query).then(res =>{
            this.stationDatasetsList = [];
            this.stationDatasetsList = res.data;
            var that = this;
            that.$nextTick(() => {
            this.stationDatasetsList.forEach((v, i) => {
                if (v.hasProject == 1) {
                    this.$refs.table1.toggleRowSelection(v, true);
                }
            });
            });
        })
        // 获取待办事项
        let itemQuery = {
          itemParentId:row.uuid
        }
        getItemListByItemParentId(itemQuery).then(res =>{
          this.itemsList = [];
          this.itemsList = res.data;
        })
      });
    },
    handleRestart(row){
      this.fileList_show = [];
      this.stationDetail = {};
      getStation(row.uuid).then(res => {
        this.stationDetail = res.data;
        this.vOpen = true;
        this.vTitle = "站点详情";
        this.fileList_show = res.data.attachList;
        this.startSatation = false;
        this.finishStation = false;
        this.nullifyStation = false;
        this.deleteStation = false;
        this.restartStation = true;
        //获取数据集
        let query = {
            stationIds: row.uuid
        }
        getBindStationDatasets(query).then(res =>{
            this.stationDatasetsList = [];
            this.stationDatasetsList = res.data;
            var that = this;
            that.$nextTick(() => {
            this.stationDatasetsList.forEach((v, i) => {
                if (v.hasProject == 1) {
                    this.$refs.table1.toggleRowSelection(v, true);
                }
            });
            });
        })
        // 获取待办事项
        let itemQuery = {
          itemParentId:row.uuid
        }
        getItemListByItemParentId(itemQuery).then(res =>{
          this.itemsList = [];
          this.itemsList = res.data;
        })
      });
    },
    handleStart(row){
      this.fileList_show = [];
      this.stationDetail = {};
      getStation(row.uuid).then(res => {
        this.stationDetail = res.data;
        this.vOpen = true;
        this.vTitle = "站点详情";
        this.fileList_show = res.data.attachList;
        this.startSatation = true;
        this.finishStation = false;
        this.nullifyStation = false;
        this.deleteStation = false;
        this.restartStation = false;
        //获取数据集
        let query = {
            stationIds: row.uuid
        }
        getBindStationDatasets(query).then(res =>{
            this.stationDatasetsList = [];
            this.stationDatasetsList = res.data;
            var that = this;
            that.$nextTick(() => {
            this.stationDatasetsList.forEach((v, i) => {
                if (v.hasProject == 1) {
                    this.$refs.table1.toggleRowSelection(v, true);
                }
            });
            });
        })
        // 获取待办事项
        let itemQuery = {
          itemParentId:row.uuid
        }
        getItemListByItemParentId(itemQuery).then(res =>{
          this.itemsList = [];
          this.itemsList = res.data;
        })
      });
    },
    handleFinish(row){
      this.fileList_show = [];
      this.stationDetail = {};
      getStation(row.uuid).then(res => {
        this.stationDetail = res.data;
        this.vOpen = true;
        this.vTitle = "站点详情";
        this.fileList_show = res.data.attachList;
        this.startSatation = false;
        this.finishStation = true;
        this.nullifyStation = false;
        this.deleteStation = false;
        this.restartStation = false;
        //获取数据集
        let query = {
            stationIds: row.uuid
        }
        getBindStationDatasets(query).then(res =>{
            this.stationDatasetsList = [];
            this.stationDatasetsList = res.data;
            var that = this;
            that.$nextTick(() => {
            this.stationDatasetsList.forEach((v, i) => {
                if (v.hasProject == 1) {
                    this.$refs.table1.toggleRowSelection(v, true);
                }
            });
            });
        })
        // 获取待办事项
        let itemQuery = {
          itemParentId:row.uuid
        }
        getItemListByItemParentId(itemQuery).then(res =>{
          this.itemsList = [];
          this.itemsList = res.data;
        })
      });
    },
    handleNullify(row){
      this.fileList_show = [];
      this.stationDetail = {};
      getStation(row.uuid).then(res => {
        this.stationDetail = res.data;
        this.vOpen = true;
        this.vTitle = "站点详情";
        this.fileList_show = res.data.attachList;
        this.startSatation = false;
        this.finishStation = false;
        this.nullifyStation = true;
        this.deleteStation = false;
        this.restartStation = false;
        //获取数据集
        let query = {
            stationIds: row.uuid
        }
        getBindStationDatasets(query).then(res =>{
            this.stationDatasetsList = [];
            this.stationDatasetsList = res.data;
            var that = this;
            that.$nextTick(() => {
            this.stationDatasetsList.forEach((v, i) => {
                if (v.hasProject == 1) {
                    this.$refs.table1.toggleRowSelection(v, true);
                }
            });
            });
        })
        // 获取待办事项
        let itemQuery = {
          itemParentId:row.uuid
        }
        getItemListByItemParentId(itemQuery).then(res =>{
          this.itemsList = [];
          this.itemsList = res.data;
        })
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.fileList_show = [];
      this.stationDetail = {};
      getStation(row.uuid).then(res => {
        this.stationDetail = res.data;
        this.vOpen = true;
        this.vTitle = "站点详情";
        this.fileList_show = res.data.attachList;
        this.startSatation = false;
        this.finishStation = false;
        this.nullifyStation = false;
        this.deleteStation = true;
        this.restartStation = false;
        //获取数据集
        let query = {
            stationIds: row.uuid
        }
        getBindStationDatasets(query).then(res =>{
            this.stationDatasetsList = [];
            this.stationDatasetsList = res.data;
            var that = this;
            that.$nextTick(() => {
            this.stationDatasetsList.forEach((v, i) => {
                if (v.hasProject == 1) {
                    this.$refs.table1.toggleRowSelection(v, true);
                }
            });
            });
        })
        // 获取待办事项
        let itemQuery = {
          itemParentId:row.uuid
        }
        getItemListByItemParentId(itemQuery).then(res =>{
          this.itemsList = [];
          this.itemsList = res.data;
        })
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.fileList_show = [];
      getStation(row.uuid).then(res => {
        this.form = res.data;
        this.open = true;
        this.title = "修改站点信息";
        this.fileList_show = res.data.attachList;
      });
    },
    listAllUser(){
      listAllUser().then(res =>{
        this.participants = res.data;
      })
    },
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 文件上传接收子组件值，同步（增）
    fileList_show_add(val){
      this.fileList_show = this.fileList_show.concat(val);
    },
    // 文件上传接收子组件值，同步（减）
    fileList_show_delet(val){
      this.fileList_show.splice(val, 1);
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.uuid != null) {
            editStation(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            editStation(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    processStartStation(row){
      this.$modal.confirm('是否确认启动站点 "' + row.name + '" 投入运营？').then(function() {
        return processStartStation(row);
      }).then(() => {
        this.getList();
        this.vOpen = false;
        this.$modal.msgSuccess("启动成功");
      }).catch(() => {});
    },
    processFinishStation(row){
      this.$modal.confirm('是否确认站点 "' + row.name + '" 关停？').then(function() {
        return processFinishStation(row);
      }).then(() => {
        this.getList();
        this.vOpen = false;
        this.$modal.msgSuccess("关停成功");
      }).catch(() => {});
    },
    processNullifyStation(row){
      this.$modal.confirm('是否确认作废站点 "' + row.name + '" ？').then(function() {
        return processNullifyStation(row);
      }).then(() => {
        this.getList();
        this.vOpen = false;
        this.$modal.msgSuccess("作废成功");
      }).catch(() => {});
    },
    processRestartStation(row){
      this.$modal.confirm('是否确认重启站点 "' + row.name + '" ？').then(function() {
        return processRestartStation(row);
      }).then(() => {
        this.getList();
        this.vOpen = false;
        this.$modal.msgSuccess("重启施工");
      }).catch(() => {});
    },
    processDeleteStation(row){
      this.$modal.confirm('是否确认删除站点 "' + row.name + '" ？').then(function() {
        return processDeleteStation(row);
      }).then(() => {
        this.getList();
        this.vOpen = false;
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/project/export', {
        ...this.queryParams
      }, `project_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
